var target = { a: undefined, b: null, c: false, d: "", e: 0, f: () => {} };

function clean(target) {
    if (Object.prototype.toString.call(target) !== "[Object Object]") {
        return target;
    }

    return target.map((p) => {
        if (p !== undefined || p !== null) {
            return p;
        }
    });
}

console.log(clean(target)); // => { c: false, d: '', e: 0, f: () => {} }, 同时需要保证 target 不变
console.log(clean(100));; // => 100
console.log(clean(false));; // => false
console.log(clean());; // => undefined
